/*
 * Copyright 2008 by Emeric Vernat
 *
 *     This file is part of MSwing.
 *
 * MSwing is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MSwing is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with MSwing.  If not, see <http://www.gnu.org/licenses/>.
 */
package mswing.print;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.swing.Icon;
import javax.swing.JTable;

import mswing.MBeanUtils;
import mswing.MImageIconCache;

/**
 * Printer Java.
 *
 * @author Emeric Vernat
 */
class MJavaPrinter extends MPrintCenter {
	/**
	 * Constructeur.
	 */
	MJavaPrinter() {
		super();
	}

	/** {@inheritDoc} */
	public void print(JTable table, OutputStream out) {
		// rien ici
	}

	/** {@inheritDoc} */
	public File getFile(JTable table) throws IOException {
		// impression directe, pas de fichier
		try {
			final java.lang.reflect.Method printMethod = table.getClass().getMethod("print",
					new Class[0]);
			MBeanUtils.invokeMethod(printMethod, table, null);
		} catch (final Exception e) {
			throw new RuntimeException(e);
		}
		return null;
	}

	/** {@inheritDoc} */
	public String getName() {
		return MParametersPrint.JAVA_PRINTER;
	}

	/** {@inheritDoc} */
	public String getFileExtension() {
		return null;
	}

	/** {@inheritDoc} */
	public boolean isOpenCheckBoxEnabled() {
		return false;
	}

	/** {@inheritDoc} */
	public Icon getIcon() {
		return MImageIconCache.getImageIcon("/icons/Print16.gif");
	}
}
